#ifndef __Scene_Scene_h__
#define __Scene_Scene_h__

#include <map>
#include <string>

#include "Scene/SceneObject.h"
#include "Scene/Camera.h"

namespace vital {

	//--------------------------------------------------------------------------
	class TScene {

	public:
		TScene();
		~TScene();

		void addObject(const std::string &name, TSceneObject *obj, unsigned long visFlags = 0xffffffff);
		TSceneObject* getObjectByName(const std::string &name);

		void step(float dt);

		void clearObjects();

		void beginRender(TCamera *camera);

		void render(unsigned long visMask = 0xffffffff);

		void endRender();

	public:
		typedef std::map<std::string, TSceneObject*> Map_t;

		class TObjectIterator {

		public:
			TObjectIterator(
				const Map_t::iterator &curr,
				const Map_t::iterator &end) {

					mCurr = curr;
					mEnd = end;
			}

			bool hasNext() {

				return mCurr != mEnd;
			}

			TSceneObject* getNext() {

				TSceneObject *obj = mCurr->second;
				mCurr++;

				return obj;
			}

		private:
			Map_t::iterator mEnd;
			Map_t::iterator mCurr;
		};

		TObjectIterator objectIterator() {

			return TObjectIterator( mObjects.begin(), mObjects.end() );
		}

	private:

		Map_t mObjects;
	};

}

#endif	// __Scene_Scene_h__